package com.example.yzx.allriddle.utils;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.yzx.allriddle.R;
import com.example.yzx.allriddle.daomain.Sort;

import java.util.List;

public class SortAdapter extends ArrayAdapter<Sort> {
    private int resourseid;
    public SortAdapter(Context context, int resource, List<Sort> objects) {
        super(context, resource, objects);
        resourseid = resource;
    }
    public View getView(int position, View convertView, ViewGroup parent) {
        Sort sort = getItem(position); //获得当前项的Hero数据
        View view= LayoutInflater.from(getContext()).inflate(resourseid,parent,false);
        ImageView iview=view.findViewById(R.id.sort_image);
        TextView tview=view.findViewById(R.id.sort_text);
        iview.setImageResource(sort.getImg());
        tview.setText(sort.getName());
        return view;
    }

}
